package edu.ccut.saturn.workflow.rollbackModule.code;

import java.sql.Connection;
import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;
import edu.ccut.saturn.operation.Operation;

public class InsertTrans extends DefaultComponent {
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		//终点活动
		String actInstId = (String)parameterContext.getParameterValue(0);
		Connection conn = parameterContext.getConnection();
		List<SaturnData> transDataList = RollbackUtil.getTransMapList(actInstId, parameterContext.getConnection());
		for(int i = transDataList.size()-1;i>=0;i--){
		    SaturnData transData = transDataList.get(i);
			Operation.dataBase().insert(transData, conn);
		}
	}
}